﻿using System;
using System.Collections.Generic;
using System.Reflection;
using log4net;

namespace AgileDashboard.AppCode
{
    /// <summary>
    /// Simple DTO used to hold story data
    /// </summary>
    [Serializable]
    public class Story : VersionOneEntity
    {
        private static Dictionary<string, string> _versionOneAttributeNameDictionary;
        private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

        /// <summary>
        /// Gets or sets the name of the iteration
        /// </summary>
        [VersionOneAttributeName("Name")]
        public string Name { get; set; }

        /// <summary>
        /// Gets or sets the description of the story
        /// </summary>
        [VersionOneAttributeName("Description")]
        public string Description { get; set; }

        /// <summary>
        /// Gets or sets the date when the story was created
        /// </summary>
        [VersionOneAttributeName("CreateDate")]
        public DateTime CreateDate { get; set; }

        /// <summary>
        /// Gets or sets the name of the impediment category the story is assigned
        /// </summary>
        [VersionOneAttributeName("Custom_ImpedimentCategory2.Name")]
        public string ImpedimentCategory { get; set; }

        /// <summary>
        /// Gets or sets the team name owning the story
        /// </summary>
        [VersionOneAttributeName("Team.Name")]
        public string Team { get; set; }

        /// <summary>
        /// Gets or sets the Version One system display ID of the story
        /// </summary>
        [VersionOneAttributeName("ID.Number")]
        public string Id { get; set; }

        /// <summary>
        /// Gets or sets the value representing the status of the story
        /// </summary>
        [VersionOneAttributeName("Status.Name")]
        public string Status { get; set; }
        
        /// <summary>
        /// Gets or sets the the value representing the theme of the story
        /// </summary>
        [VersionOneAttributeName("Parent.Name")]
        public string Theme { get; set; }        

        /// <summary>
        /// Gets or sets the the value representing the referenced asset
        /// </summary>
        [VersionOneAttributeName("Reference")]
        public string Reference { get; set; }

        public static Dictionary<string, string> VersionOneAttributeNameDictionary
        {
            get
            {
                if (Log.IsDebugEnabled)
                {
                    Log.DebugFormat("Returning instance of Story Attribute Name Dictionary");
                }
                return _versionOneAttributeNameDictionary
                       ?? (_versionOneAttributeNameDictionary = BuildVersionOneAttributeDictionary<Story>());
            }
        }

    }
}